package com.controller.manager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.po.StudentBeanW;
import com.service.manager.StuServiceW;

@Controller
@RequestMapping("/jsp")
public class StuController {
	
	@Resource(name = "stuServiceImpW")
	private StuServiceW stuService;
	
	@ResponseBody
	@RequestMapping(value="/getStuList")
	public List<StudentBeanW> getStuList(StudentBeanW stu,Integer page,Integer rows){
		stu.setPage(((page-1)*rows));
		stu.setRows(rows);
		System.out.println(stu.getPage()+" "+stu.getRows());
		List<StudentBeanW> list = stuService.getStuList(stu);
		int count = stuService.getStuCount(stu);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("rows", list);
		map.put("total", count);
		return list;
	}
	
	@ResponseBody
	@RequestMapping(value="/delStu")
	public int delStudent(String stuid){
		int result = stuService.delStudent(stuid);
		return result;
	}
	
	/** 	
	 * 批量删除
	 * @param list
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/delStuList")
	public int delStuList(String stuids){
		System.out.println(stuids);
		String[] stuarry =stuids.split(",");
		int result = stuService.delStuList(stuarry);
		return result;
	}
	/**
	 * 更新stu
	 * @param stu
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/updateStu")
	public int updateStu(StudentBeanW stu){
		System.out.println(stu.getStuclass());
		int result = stuService.updateStu(stu);
		return result;
	}
}
